from socket import *

ADDR = ("127.0.0.1", 8888)  # 服务端地址
file = "/home/tarena/下载/peng.jpeg"


def send_image(sock):
    fr = open(file, 'rb')
    while True:
        data = fr.read(1024)
        if not data:
            break
        sock.send(data)
    fr.close()


def main():
    sock = socket()
    sock.connect(ADDR)
    send_image(sock)
    sock.close()  # 断开


if __name__ == '__main__':
    main()
